package com.mgkj.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mgkj.common.result.Result;
import com.mgkj.dto.yf.MOCTCDto;
import com.mgkj.mapper.InitMoctcMapper;

import com.mgkj.service.MoctcService;
import com.mgkj.vo.yf.MoctcVo;
import com.mgkj.vo.yf.kwVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class MoctcServiceImpl implements MoctcService {

    @Resource
    private InitMoctcMapper moctcMapper;
    @Override
    public Result getmoctf(Integer current, Integer size, MOCTCDto moctcDto) {
        PageHelper.startPage(current,size);
        List<MoctcVo> list=moctcMapper.getmoctc(moctcDto);
        for (MoctcVo moctcVo:list){
            List<kwVO> kwVOList=moctcMapper.selectkw(moctcVo.getTe004());
            moctcVo.setKwnumber(kwVOList);
        }
        PageInfo<MoctcVo> moctgVoPageInfo = new PageInfo<>(list);
        Map<String,Object> map = new HashMap<>();
        map.put("pages", moctgVoPageInfo.getPages());
        map.put("total", moctgVoPageInfo.getTotal());
        map.put("list", list);
        return Result.ok(map);
    }
}
